package com.example.star.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.star.R;
import com.example.star.entity.Song;
import java.util.List;

public class SongAdapter extends ArrayAdapter<Song> {
    private Context mContext;

    public SongAdapter(Context context, List<Song> songs) {
        super(context, 0, songs);
        mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Song song = getItem(position);

        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item_songs, parent, false);
        }
        ImageView SongImage = convertView.findViewById(R.id.image_song);
        TextView SongName = convertView.findViewById(R.id.song_name);
        TextView SingerName = convertView.findViewById(R.id.singer_name);

        SongName.setText(song.getSongname());
        SingerName.setText(song.getSingername());

        return convertView;
    }

}